package com.regent.central.bill.repository;

import com.regent.central.bill.core.ReturnGoods;
import com.regent.central.bill.dto.sale_order.SaleOrderDetailReturnGoodsDTO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.math.BigDecimal;
import java.util.List;

@Repository
public interface ReturnGoodsMapper extends Mapper<ReturnGoods> {

    /**
     * 获取指定销售单的退货总额
     *
     * @param saleOrderId 销售单ID
     * @return 该销售单的退货总额
     */
    BigDecimal getReturnGoodsAmount(
            @Param("saleOrderId") String saleOrderId
    );

    /**
     * 获取指定销售单的退货总数
     *
     * @param saleOrderId 销售单ID
     * @return 该销售单的退货总数
     */
    BigDecimal getReturnGoodsTotal(
            @Param("saleOrderId") String saleOrderId
    );

    /**
     * 获取销售单详情退货货品列表
     *
     * @param saleOrderId 销售单ID
     * @return 销售单详情退货货品列表
     */
    List<SaleOrderDetailReturnGoodsDTO> getSaleOrderDetailReturnGoods(
            @Param("saleOrderId") String saleOrderId
    );

    /**
     * 删除退货货品
     *
     * @param returnGoodsId 退货货品ID
     * @param userDeleted   删除人
     * @param timeDeleted   删除时间
     */
    void hide(
            @Param("returnGoodsId") String returnGoodsId,
            @Param("userDeleted") String userDeleted,
            @Param("timeDeleted") long timeDeleted
    );

    /**
     * 根据退货动作ID删除退货货品
     *
     * @param returnActionId 退货动作ID
     * @param userDeleted    删除人
     * @param timeDeleted    删除时间
     */
    void deleteForSaleOrderReturnAction(
            @Param("returnActionId") String returnActionId,
            @Param("userDeleted") String userDeleted,
            @Param("timeDeleted") long timeDeleted
    );

    /**
     * /**
     * 获取销售单的退货货品
     *
     * @param saleOrderId 销售单ID
     * @param canceled    已撤销
     * @param deleted     已删除
     * @return 销售单的退货货品
     */
    List<ReturnGoods> getSaleOrderReturnGoods(
            @Param("saleOrderId") String saleOrderId,
            @Param("canceled") Boolean canceled,
            @Param("deleted") Boolean deleted
    );

}